package com.manage.action;

import java.util.List;

import org.apache.log4j.Logger;

import com.action.AbstractAction;
import com.manage.cache.ConfirmTemplateManager;
import com.manage.model.ConfirmTemplate;

public class ConfirmTemplateAction extends AbstractAction {
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	private Logger logger;
	
	public ConfirmTemplateAction()
	{
		logger = Logger.getLogger(this.getClass());
	}
	
	public String execute()
	{
		return SUCCESS;
	}

	private List<ConfirmTemplate> list;
	private ConfirmTemplate       model;
	private String        type;
	
	public String list()
	{
		logger.debug("list ConfirmTemplateAction");
		list = ConfirmTemplateManager.getInstance().getConfirmTemplates();
		return SUCCESS;
	}
	
	public String show()
	{
		if (model != null && model.getId() >= 0)
		{
			model = ConfirmTemplateManager.getInstance().getConfirmTemplate(model.getId());
			type = "update";
		}
		else
		{
			model = new ConfirmTemplate();
			model.setId(-1);
			type = "insert";
		}

		return SUCCESS;
	}
		
	public String save()
	{
		
		ConfirmTemplateManager.getInstance().saveConfirmTemplate(type, model);
		return SUCCESS;
	}

	public List<ConfirmTemplate> getList() {
		return list;
	}

	public void setList(List<ConfirmTemplate> list) {
		this.list = list;
	}

	public ConfirmTemplate getModel() {
		return model;
	}

	public void setModel(ConfirmTemplate model) {
		this.model = model;
	}

	public String getType() {
		return type;
	}

	public void setType(String type) {
		this.type = type;
	}

	
	
}
